/*
 * @Author: LIFM0623 1944099171@qq.com
 * @Date: 2024-02-22 20:22:51
 * @LastEditors: LIFM0623 1944099171@qq.com
 * @LastEditTime: 2024-03-29 20:40:26
 * @FilePath: \scene_back_nest\src\dynamiclayer\dynamiclayer.controller.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Req,
} from '@nestjs/common';
import { DynamiclayerService } from './dynamiclayer.service';
import {
  RawDynamiclayerDto,
} from './dto/create-dynamiclayer.dto';
import { UpdateDynamiclayerDto } from './dto/update-dynamiclayer.dto';
import { Request } from 'express';


@Controller('dynamiclayer')
export class DynamiclayerController {
  constructor(private readonly dynamiclayerService: DynamiclayerService) {}

  @Post('createDynamiclayerItem')
  create(@Body() rawDynamiclayerDto: RawDynamiclayerDto, @Req() request: Request) {
    const user = request.user;
    rawDynamiclayerDto.creator = (user as any).email;
    return this.dynamiclayerService.create(rawDynamiclayerDto);
  }

  @Get('findAll')
  findAll() {
    return this.dynamiclayerService.findAll();
  }

  @Get('findOne/:id')
  findOne(@Param('id') id: string) {
    return this.dynamiclayerService.findOne(id);
  }

  @Patch('update/:id')
  update(
    @Param('id') id: string,
    @Body() updateDynamiclayerDto: UpdateDynamiclayerDto,
  ) {
    return this.dynamiclayerService.update(id, updateDynamiclayerDto);
  }

  @Delete('remove/:id')
  remove(@Param('id') id: string) {
    return this.dynamiclayerService.remove(id);
  }
}
